package com.own.business.elasticsearch.controller;

import com.own.aop.permission.PermissionModule;
import com.own.aop.permission.PermissionOperation;
import com.own.business.selasticsearch.business.entity.query.IndexManagementIndicesQuery;
import com.own.business.selasticsearch.business.entity.vo.IndexManagementIndicesVo;
import com.own.business.selasticsearch.business.service.ElasticsearchIndexManagementService;
import com.own.component.common.base.controller.BaseController;
import com.own.component.common.model.PageModel;
import com.own.component.common.model.R;
import com.own.component.common.model.ResultModel;
import com.own.component.log.operation.aop.LogOperationAop;
import com.own.constant.ConstantApiPrefix;
import com.own.constant.ConstantBeanSuffix;
import com.own.constant.ConstantPermission;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * ElasticsearchIndexManagementController
 *
 * @author chenxueli
 * @date 2024-05-08 13:02:04
 */
@Slf4j
@Tag(name = "索引管理" + ConstantBeanSuffix.CONTROLLER)
@RestController
@PermissionModule("elasticsearch-index-management")
@RequestMapping(ConstantApiPrefix.BASE_API_V1_PREFIX + ConstantApiPrefix.MANAGE_CLIENT + "elasticsearch/index/management")
public class ElasticsearchIndexManagementController extends BaseController {

    @Resource
    private ElasticsearchIndexManagementService elasticsearchIndexManagementService;

    @LogOperationAop
    @PermissionOperation(ConstantPermission.SEARCH)
    @Operation(summary = "分页查询信息")
    @PostMapping("/page")
    public ResultModel<PageModel<IndexManagementIndicesVo>> page(
            @RequestBody IndexManagementIndicesQuery query
    ) {
        var pageModel = elasticsearchIndexManagementService.page(query);
        return R.success(pageModel);
    }

}
